package Oracle;

import oracle.jdbc.OracleTypes;
import oracle.jdbc.oracore.OracleType;

import java.sql.*;

public class dbutils {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcla","AL","000000");
        System.out.println(conn);
        CallableStatement csp = conn.prepareCall("{call mytestcursor(?)}");
//        csp.setObject(1,7788);
        csp.registerOutParameter(1, OracleTypes.CURSOR);//游标
                                                    //java.jdbc,type 获取基本返回值
        Object obj = csp.execute();
        ResultSet res = (ResultSet) csp.getObject(1);
        int i = 1;
        while (res.next()){
            ResultSetMetaData metaData = res.getMetaData();//获取结果集结构
            metaData.getColumnCount();
            System.out.println(res.getString(1));//resultset可以通过1234来获得值
        }

    }
}
